import React, {useState,useContext,useEffect} from 'react';
import ReactDOM from 'react-dom'
import { base, createPage, getMetaKey } from 'nc-lightapp-front';
import { AppContext } from "../../reHook/start";
import { getQueryCondition } from '../../../../../hrpub/common/utils/utils';
import './index.less';

const b = {
    "data":{
        "validateFlag":false,
        "hi_psndoc_abroad":{
            "items":[
                {
                    "queryOperateType":"=@<>@>@>=@<=@<@like@left like@right like@not like@between@ISNULL@ISNOTNULL@",
                    "isfixedcondition":false,
                    "visibleposition":"0",
                    "usefunc":false,
                    "checkStrictly":false,
                    "col":"0",
                    "colnum":"1",
                    "hyperlinkflag":false,
                    "isnextrow":false,
                    "leftspace":"0",
                    "rightspace":"0",
                    "rows":"0",
                    "attrcode":"begindate",
                    "containlower":false,
                    "datatype":"39",
                    "disabled":false,
                    "editAfterFlag":false,
                    "fieldDisplayed":"refname",
                    "fieldValued":"refpk",
                    "isDataPowerEnable":false,
                    "isnotmeta":false,
                    "isResLabel":false,
                    "isrevise":false,
                    "isShowUnit":false,
                    "itemtype":"datePickerNoTimeZone",
                    "label":"起始日期",
                    "maxlength":"10",
                    "onlyLeafCanSelect":false,
                    "position":"0",
                    "required":false,
                    "scale":"0",
                    "visible":true
                },
                {
                    "queryOperateType":"=@<>@>@>=@<=@<@like@left like@right like@not like@between@ISNULL@ISNOTNULL@",
                    "isfixedcondition":false,
                    "visibleposition":"0",
                    "usefunc":false,
                    "checkStrictly":false,
                    "col":"0",
                    "colnum":"1",
                    "hyperlinkflag":false,
                    "isnextrow":false,
                    "leftspace":"0",
                    "rightspace":"0",
                    "rows":"0",
                    "attrcode":"enddate",
                    "containlower":false,
                    "datatype":"39",
                    "disabled":false,
                    "editAfterFlag":false,
                    "fieldDisplayed":"refname",
                    "fieldValued":"refpk",
                    "isDataPowerEnable":false,
                    "isnotmeta":false,
                    "isResLabel":false,
                    "isrevise":false,
                    "isShowUnit":false,
                    "itemtype":"datePickerNoTimeZone",
                    "label":"终止日期",
                    "maxlength":"10",
                    "onlyLeafCanSelect":false,
                    "position":"0",
                    "required":false,
                    "scale":"0",
                    "visible":true
                },
                {
                    "queryOperateType":"=@<>@>@>=@<=@<@like@left like@right like@not like@between@ISNULL@ISNOTNULL@",
                    "isfixedcondition":false,
                    "visibleposition":"0",
                    "usefunc":false,
                    "checkStrictly":false,
                    "col":"0",
                    "colnum":"1",
                    "hyperlinkflag":false,
                    "isnextrow":false,
                    "leftspace":"0",
                    "rightspace":"0",
                    "rows":"0",
                    "attrcode":"abroaddate",
                    "containlower":false,
                    "datatype":"39",
                    "disabled":false,
                    "editAfterFlag":false,
                    "fieldDisplayed":"refname",
                    "fieldValued":"refpk",
                    "isDataPowerEnable":false,
                    "isnotmeta":false,
                    "isResLabel":false,
                    "isrevise":false,
                    "isShowUnit":false,
                    "itemtype":"datePickerNoTimeZone",
                    "label":"出国(出境)时间",
                    "maxlength":"10",
                    "onlyLeafCanSelect":false,
                    "position":"0",
                    "required":false,
                    "scale":"0",
                    "visible":true
                },
                {
                    "isfixedcondition":false,
                    "visibleposition":"0",
                    "usefunc":false,
                    "checkStrictly":false,
                    "col":"0",
                    "colnum":"1",
                    "hyperlinkflag":false,
                    "isnextrow":false,
                    "leftspace":"0",
                    "rightspace":"0",
                    "rows":"0",
                    "attrcode":"abroadway",
                    "containlower":false,
                    "datatype":"57",
                    "disabled":false,
                    "editAfterFlag":false,
                    "fieldDisplayed":"refname",
                    "fieldValued":"refpk",
                    "isDataPowerEnable":false,
                    "isnotmeta":false,
                    "isResLabel":false,
                    "isrevise":false,
                    "isShowUnit":false,
                    "itemtype":"refer",
                    "label":"出国(出境)目的",
                    "maxlength":"20",
                    "metadataProperty":"uap.Defdoc-HRHI011_0xx.name",
                    "onlyLeafCanSelect":false,
                    "pk_defdoclist":"1001Z71000000000GP57",
                    "position":"0",
                    "refcode":"uapbd/refer/userdef/DefdocGridRef/index",
                    "refName_db":"出国目的代码(自定义档案)",
                    "required":false,
                    "scale":"0",
                    "visible":true
                },
                {
                    "isfixedcondition":false,
                    "visibleposition":"0",
                    "usefunc":false,
                    "checkStrictly":false,
                    "col":"0",
                    "colnum":"1",
                    "hyperlinkflag":false,
                    "isnextrow":false,
                    "leftspace":"0",
                    "rightspace":"0",
                    "rows":"0",
                    "attrcode":"abroadarea",
                    "containlower":false,
                    "datatype":"204",
                    "disabled":false,
                    "editAfterFlag":false,
                    "fieldDisplayed":"refname",
                    "fieldValued":"refpk",
                    "isDataPowerEnable":false,
                    "isnotmeta":false,
                    "isResLabel":false,
                    "isrevise":false,
                    "isShowUnit":false,
                    "itemtype":"refer",
                    "label":"所去国家(地区)",
                    "maxlength":"20",
                    "metadataProperty":"uap.countryzone.name",
                    "onlyLeafCanSelect":false,
                    "position":"0",
                    "refcode":"uapbd/refer/pubinfo/CountryDefaultGridRef/index",
                    "required":false,
                    "scale":"0",
                    "visible":true
                },
            ],
        }
    },
    "success":true
}
function QueryConfirm (props) {

    useEffect(async() => {
        let template = props.meta.getMeta();
        template['ConditionQuery'] = {
            code: "ConditionQuery",
            isclosequickquery: false,
            isnotmeta: false,
            isunfold: true,
            moduletype: "search",
            name: "查询",
            oid: '1001Z710000000003DX7' 
        }
        template['ConditionQuery'].items = b.data['hi_psndoc_abroad'].items;
        console.log(template)
        await props.meta.setMeta(template)
        props.search.openAdvSearch('ConditionQuery', true)
        // if(document.getElementsByClassName('modalHead super-handle')) {
        //     let a = document.getElementsByClassName('modalHead super-handle');
        //     a.remove();
        //     console.log('ddd')
        // }
    }, [])

    const goSearch = () => {
        console.log(props.search.getQueryInfo('ConditionQuery'))
        let searchData = getQueryCondition(props, 'ConditionQuery')
        console.log(searchData)
        // formData，meta_data_id，prefix，suffix，dataFormat
       
    }
    console.log()
    return  <div style={{
            display: 'none',
        }}>
            {/* 测试 */}
            {props.search.NCCreateSearch('ConditionQuery', {
                searchBtnName: '确定',
                onlyShowAdvArea: false,
                showAdvSearchPlanBtn: true,
                saveSearchPlan: true,
                onlyShowSuperBtn: true,
                backdrop: false,
                clickSearchBtn: goSearch
            })}
        </div>
}

export default createPage({})(QueryConfirm)
